/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef FONT_FONT_LIBA_H
#define FONT_FONT_LIBA_H

#include <xml/Object.h>
#include <filesystem/String.hpp>
#include "AbstractFont.h"

namespace liba
{

namespace resource {
	class Resource;
}

namespace font
{

class Proportional 
	: public xml::ObjectUnicode
	, public AbstractFont
{
public:
	struct Letter :
		public xml::ObjectUnicode
	{
		wchar_t symbol;
		int x, y;
		int width, height;
		int base_skip;
		int base_width;

		Letter();
		Letter(const Letter & other);
	protected:
		virtual bool on_attribute( xml::Provider * prov, const std::wstring & name, const std::wstring & value );
	};
	Proportional(resource::Resource* resource, const filesystem::String & name);
	Proportional(const Proportional & other);
	~Proportional();
	const Letter & get_letter(wchar_t symbol)const;
	int get_base()const
	{
		return base;
	}
	double get_line_shift()const
	{
		return line_shift;
	}
	double get_width()const
	{
		return width;
	}
	double get_height()const
	{
		return height;
	}
	virtual Proportional * clone()
	{
		return new Proportional(*this);
	}
public:
	virtual void Accept(FontVisitor* visitor);
protected:
	virtual bool on_attribute( xml::Provider * prov, const std::wstring & name, const std::wstring & value );
	virtual bool on_node( xml::Provider * prov, const std::wstring & name );
private:
	std::map<wchar_t, Letter> letters;
	Letter not_found_letter;
	int height;
	int width;
	int base;
	double line_shift;
};

} //namespace font
} //namespace liba

using namespace liba;

#endif //FONT_FONT_LIBA_H
